package com.forbet.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.forbet.demo.po.AsianBankerInfoPO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AsianBankerInfoMapper extends BaseMapper<AsianBankerInfoPO> {

    @Select("SELECT * FROM ( " +
            "SELECT *, ROW_NUMBER() OVER(PARTITION BY banker_name ORDER BY create_time DESC) AS row_num " +
            "FROM asian_banker_info " +
            "WHERE play_info_id = #{id} AND start_now_handicap_flag = #{flag} " +
            ") t WHERE row_num = 1")
    List<AsianBankerInfoPO> findLatestByBankerName(@Param("id") Long id, @Param("flag") String flag);
}
